def add_time(start, duration, day=''):
    if day != '':
        day = day.title()
    sta = start.split(':', 2)
    sta[1:3] = sta[1].split(' ', 2)
    dur = duration.split(':', 2)
    dur[1:3] = dur[1].split(' ', 2)
    hour, min = int(sta[0]), int(sta[1])
    ahour, amin = int(dur[0]), int(dur[1])
    hour_sum = hour + ahour + (min+amin)//60
    new_hour = hour_sum % 12
    new_min = min + amin if (min + amin) < 60 else min+amin-60

    week = ['Monday', 'Tuesday', 'Wednesday',
            'Thursday', 'Friday', 'Saturday', 'Sunday']
    if sta[2] == 'AM':
        n = hour_sum // 24
        if hour_sum < 12 or hour_sum//12 % 2 == 0:
            sta[2] = 'AM'
        elif 12 <= hour_sum < 24 or hour_sum//12 % 2 != 0:
            sta[2] = 'PM'

    elif sta[2] == 'PM':
        if hour_sum//12 % 2 != 0:
            sta[2] = 'AM'
            n = hour_sum // 24 + 1
        elif hour_sum//12 % 2 == 0:
            sta[2] = 'PM'
            n = hour_sum // 24

    if new_hour == 0:
        new_hour = 12

    new_hour = str(new_hour)
    new_min = str(new_min).zfill(2)
    if n:
        days = 'next day' if n == 1 else ('%d days later' % n)
        if day in week:
            new_day = week[(week.index(day)+n) % 7]
            new_time = ('%s' + ':' + '%s ' +
                        sta[2]+', %s ' + '(%s)') % (new_hour, new_min, new_day, days)
        else:
            new_time = ('%s' + ':' + '%s ' +
                        sta[2]+' '+'(%s)') % (new_hour, new_min, days)
    else:
        if day in week:
            new_day = week[(week.index(day)+n) % 7]
            new_time = ('%s' + ':' + '%s ' +
                        sta[2]+', '+'%s') % (new_hour, new_min, new_day)
        else:
            new_time = ('%s' + ':' + '%s ' + sta[2]) % (new_hour, new_min)
    return new_time


if __name__ == "__main__":
    print(add_time("9:15 PM", "5:30"))
    print(add_time("2:59 AM", "24:00", "saturDay"))
    # print(add_time("2:59 AM", "24:00", "SaturDay"))
    # print(add_time("3:00 PM", "3:10"))
    # print(add_time("11:30 AM", "2:32", "Monday"))
    # print(add_time("11:43 AM", "00:20"))
    # print(add_time("10:10 PM", "3:30"))
    # print(add_time("11:43 PM", "24:20", "tueSday"))
    # print(add_time("6:30 PM", "205:12"))
